<?php

namespace app\api\model;

use app\common\model\Category as CategoryModel;

/**
 * 商品分类模型
 * Class Category
 * @package app\common\model
 */
class Category extends CategoryModel
{
    /**
     * 隐藏字段
     * @var array
     */
    protected $hidden = [
        'wxapp_id',
//        'create_time',
        'update_time'
    ];

    /**
     * 获取二级分类
     *
     * @param $id
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public static function getList($id) {
        if(empty($id) || $id == 1){
            $id = 1;
        }else if($id == 2){
            $id = 2;
        }
        $list = CategoryModel::where('parent_id',$id)->select();
        if(!empty($list)){
            $status = ['code'=>1,'msg'=>'查询成功','data'=>$list];
        }else{
            $status = ['code'=>0,'msg'=>'暂无其他分类','data'=>''];
        }
        return $status;
    }

}
